package cloud.maque.admin.impl;


import cloud.maque.admin.domain.entity.MqUserRole;
import cloud.maque.admin.mapper.MqUserRoleMapper;
import cloud.maque.admin.service.MqUserRoleService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhuyf
 * @date 2023/3/2 9:59
 */
@Service
public class MqUserRoleServiceImpl extends ServiceImpl<MqUserRoleMapper, MqUserRole> implements MqUserRoleService {

    @Override
    public void AddUserRole(List<MqUserRole> userRoles) {

        this.saveBatch(userRoles);
    }

    @Override
    public Boolean deleteByRoleId(String roleId) {
        QueryWrapper<MqUserRole> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(MqUserRole::getRoleId, roleId);
        return remove(queryWrapper);
    }

    @Override
    public List<MqUserRole> GetUserRoles(String userId) {
        QueryWrapper<MqUserRole> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(MqUserRole::getUserId, userId);
        return baseMapper.selectList(queryWrapper);
    }

    @Override
    public Boolean deleteByUserId(String userId) {
        QueryWrapper<MqUserRole> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(MqUserRole::getUserId, userId);
        return remove(queryWrapper);
    }
}
